package com.cuicui.mall.controller;

import com.cuicui.mall.annotation.LogRecorder;
import com.cuicui.mall.service.LogService;
import com.cuicui.mall.utils.CommonResponse;
import com.cuicui.mall.vo.LogVO;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/log")
@Tag(name = "日志管理")
public class LogController {

    @Autowired
    private LogService logService;

    /**
     * @param userName     用户名
     * @param pageNo   页数
     * @param pageSize 单页数量
     * @return CommonResponse<PageInfo < UserVO>> 分页的用户列表
     */
    @GetMapping("/logPage")
    @Operation(summary = "日志分页")
    @LogRecorder(operation = "日志分页查询")
    public CommonResponse<PageInfo<LogVO>> getPage(
            @RequestParam(required = false, defaultValue = "") String userName,
            @RequestParam(required = false, defaultValue = "1") Integer pageNo,
            @RequestParam(required = false, defaultValue = "20") Integer pageSize) {
        return CommonResponse.success(logService.getPage(userName, pageNo, pageSize));
    }
}
